﻿@{
    ViewBag.Title = "Send Email";
    Layout = "~/Areas/Administrator/Views/Shared/_AdminLayout.cshtml";
}
@using CoreData
@model SendMail
@using Helper
<div class="row-fluid">
    <div class="span12">
        <div class="head">
            <div class="isw-documents">
            </div>
            <h1>
                Detail</h1>
            <div class="clear">
            </div>
        </div>
        <div class="block-fluid tabs">
            <ul>
                <li><a href="#tabs-1">Content</a></li>
            </ul>
            @using (Ajax.BeginForm("SendMail", "EmailListManagement", new AjaxOptions { OnSuccess = "SuccessSendMail", HttpMethod = "Post" }, new { enctype = "multipart/form-data", @id = "validation" }))
            {
                <div class="warning-area">
                </div>
                <div id="tabs-1">
                    <div class="row-form">
                        <div class="span2">
                            Send to:</div>
                        <div class="span9">
                            @Html.TextBoxFor(x => x.emailto)</div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="row-form">
                        <div class="span2">
                            Title:</div>
                        <div class="span9">
                            @Html.TextBoxFor(x => x.subject, new { @class = "validate[required]" })</div>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="row-form">
                        <div class="span2">
                            Template:</div>
                        <div class="span9">
                            @Html.DropDownListFor(x => x.EmailTemplateID, Model.ListTemplateExt, new { @class = "validate[required]" })</div>
                        <div class="clear">
                        </div>
                    </div>
                </div>
                <div class="row-form">
                    <div class="span2">
                        Body</div>
                    <div class="span9">
                        @Html.TextAreaFor(x => x.body, new { @cols = "10", @rows = "10" })</div>
                    <div class="clear">
                    </div>
                </div>
                if (Helper.SessionManagement.Value("pvalue").Contains("C") || Helper.SessionManagement.Value("pvalue").Contains("U"))
                {
                <div class="row-form">
                    <div class="span2">
                    </div>
                    <div class="span9">
                        <input type="submit" class="btn btn-info span3" value="Update" /></div>
                    <div class="clear">
                    </div>
                </div>
                }

            }
        </div>
    </div>
</div>
<script src="@Url.ContentArea("~/Content/javascript/emaillist.js")" type="text/javascript"></script>
<script type="text/javascript">
    ///Document Ready jQuery
    $(document).ready(function () {
        CKEDITOR.replace("body", { filebrowserBrowseUrl: '/Content/Filemanager/index.html' });
    });
    $("#EmailTemplateID").change(function () {
        var id=$("#EmailTemplateID").val();
        if(id>0){
            $.ajax({
                type: 'get',
                url: '@Url.Action("GetEmailTemplateBody", "EmailListManagement")',
                dataType: 'json',
                data: { id: id },
                contentType: "application/json; charset=utf-8",
                //traditional: true,
                success: function (edata) {
                    CKEDITOR.instances['body'].setData(edata.Template);
                },
                error: function () {
                    return;
                }
            });
        }
        else {
            CKEDITOR.instances['body'].setData("");
        }
    });
</script>
